<template>
  <z-modal ref="zModalRef" :title="title">
    <z-form
      ref="zFormRef"
      :schemas="schemas"
      submitActionText="确认"
      resetActionText=""
    >
      <template #formActionBefore>
        <n-button @click="() => zModalRef.close()"> 取消 </n-button>
      </template>
    </z-form>
  </z-modal>
</template>

<script lang="ts" setup>
import { ref } from "vue";
import { ZFormItemSchema } from "../Form/typings";
import { ZModalFormMethods } from "./typings";

export interface ZModalFormProps {
  width?: number | string;
  title: string;
  schemas: ZFormItemSchema[];
}
const props = withDefaults(defineProps<ZModalFormProps>(), {
  title: "",
  schemas: () => [],
});

const zModalRef = ref();
const zFormRef = ref();

const modalMethods: ZModalFormMethods = {
  modal: zModalRef,
  form: zFormRef,
};

/* expose */
defineExpose(modalMethods);
</script>
